package com.hang.controller;

import com.hang.entity.Message;
import com.hang.service.IMessageService;
import com.hang.service.impl.MessageServiceImpl;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Optional;

@RestController
@RequestMapping("test")
public class TestController {

    @Resource
    private IMessageService messageService;

    @GetMapping("/test")
    public void test(){
        Integer messageCount = Optional
                .ofNullable(
                        messageService.lambdaQuery()
                                .eq(Message::getReceiveId, 100001)
                                .eq(Message::getIsRead, 0)
                                .count()
                )
                .orElse(0);
    }
}
